package kernel.process;

import java.util.ArrayList;
import java.util.List;

/**
 * Object that describes new process to be created. Doesn't include abstract methods
 * @author Jaromir Lepic, Petr Hajek, Veronika Vebcurikova
 *
 */
public class AbstractProcessHeader {
	protected String name;
	protected List<String> params;
	protected String input;
	protected String output;
	protected boolean append;
	protected long shellID;
	protected String userID;

	/**
	 * Constructs a new AbstractProcessHeader object. 
	 * @param name			Name of the command (the name of the process is similar).
	 * @param params		Parameters of the command saved in the array.
	 * @param input			ABSOLUTE PATH of the input file (if there's no input stream, this string is empty)
	 * @param output		ABSOLUTE PATH of the output file (if there's no output stream, this string is empty)
	 * @param append		If process should APPEND (>>) the output data to a file, this variable is true; false otherwise
	 */
	public AbstractProcessHeader(String name, List<String> params, String input, String output, boolean append, long shellID, String userID) {
		this.name = name;
		if (params == null) {
			this.params = new ArrayList<String>();
		} else {
			this.params = params;
		}
		this.input = input;
		this.output = output;
		this.append = append;
		this.shellID = shellID;
		this.userID = userID;
	}

	public String getName() {
		return name;
	}

	public AbstractProcessHeader setUserID(String user){
		this.userID = user;
		return this;
	}
	
	public List<String> getParams() {
		return params;
	}
	
	public String getInput() {
		return input;
	}

	public String getOutput() {
		return output;
	}
	
	public boolean getAppend() {
		return append;
	}
	
	public long getShellID() {
		return shellID;
	}
	
	public String getUserID() {
		return userID;
	}

	public AbstractProcessHeader setParams(List<String> params) {
		this.params = params;
		return this;
	}

	public AbstractProcessHeader setInput(String input) {
		if (input == null)
			this.input = "";
		else
			this.input = input;
		return this;
	}

	public AbstractProcessHeader setOutput(String output) {
		if (output == null)
			this.output = "";
		else
			this.output = output;
		return this;
	}

	public AbstractProcessHeader setAppend(boolean append) {
		this.append = append;
		return this;
	}
	
	public AbstractProcessHeader setName(String name){
		this.name = name;
		return this;
	}

}
